<?php

error_reporting(E_ALL);

/**
 * untitledModel - class.ModeloCursos.php
 *
 * $Id$
 *
 * This file is part of untitledModel.
 *
 * Automatically generated on 04.12.2011, 19:24:30 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include Conexion
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Conexion.php');

/* user defined includes */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B00-includes begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B00-includes end

/* user defined constants */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B00-constants begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B00-constants end

/**
 * Short description of class ModeloCursos
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloCursos
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method GetAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function GetAllRows()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B01 begin
		$sql = "SELECT idcurso, nombre ,categoria , descrip, iduser, maestro  FROM cursos,(select iduser, nombre as maestro from usuarios)as tabla where usuarios_iduser = iduser;";		
		return $this->ejecutarQuery($sql);
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B01 end
    }

    /**
     * Short description of method GetId
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function GetId($id)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B03 begin
		$sql = "SELECT * FROM cursos where idcurso=".$id;		
		return $this->ejecutarQuery($sql);
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B03 end
    }

    /**
     * Short description of method InsertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function InsertRow($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B06 begin
		$sql = "INSERT INTO cursos (
			nombre,
			categoria,
			descrip,
			usuarios_iduser
			) VALUES (
			'".$datos['nombre']."',
			'".$datos['categoria']."',
			'".$datos['descrip']."',
			".$datos['iduser']."		
			)";
		$this->ejecutarQuery($sql);
		return mysql_insert_id();    
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B06 end
    }

    /**
     * Short description of method UpdateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function UpdateRow($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B09 begin
		$sql= "
			UPDATE cursos SET 
				nombre = '".$datos['nombre']."',
				categoria = '".$datos['categoria']."',
				descrip = '".$datos['descrip']."',				
				usuarios_iduser = ".$datos['iduser']." 
				where idcurso=".$datos['idcurso'].";
		";
		$this->ejecutarQuery($sql);      
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B09 end
    }

    /**
     * Short description of method DeleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function DeleteRow($id)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0C begin
		$sql= "DELETE FROM cursos WHERE idcurso=".$id;
		$this->ejecutarQuery($sql);
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0C end
    }
	
	 public function SelectMaestro()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0C begin
		$sql= "select * from usuarios where nivel =2";
		return $this->ejecutarQuery($sql);   
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0C end
    }

    /**
     * Short description of method SearchByName
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  nombre
     * @return mixed
     */
    public function SearchByName($nombre)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0F begin
		
		$sql= "SELECT * FROM cursos where nombre='".$nombre."'";
		$this->ejecutarQuery($sql);
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B0F end
    }

} /* end of class ModeloCursos */

?>